let dvs = document.querySelector('.uls')
let backup = document.querySelector('.backup')
let fhzy = document.querySelector('.fhzy')
let categoryId = getQueryString('categoryId')
console.log(categoryId)
fetch(`http://chst.vip:1234/api/getproductlist?categoryid=${categoryId}`)
    .then(body => body.json())
    .then(res => {
        // console.log(res.result)
        // console.log(res.result.)
        let regExp = /(?<=imgurl=)[^'"]*/;
        let r = res.result;
        console.log(r)
        // console.log(r[0].productId)
        let el = '';
        r.forEach(item => {
            el += `<li productId=${item.productId}>
         <div class="imgs">
             ${item.productImg}
         </div>
         <div class="wenzi">
             <p>${item.productName}</p>
             <p>${item.productPrice}</p>
             <p>${item.productQuote} <img src="../imges/pl.png" alt="">${item.productCom} </p>
         </div>
     </li> `
        })
        
        dvs.innerHTML = el
        $('.uls').on('click','li',function(){
            console.log($(this))
            let productId = $(this).attr('productId')
            console.log(productId)
            location.href=`./page1-1-1.html?productId=${productId}`
        })

    })

fetch(`http://chst.vip:1234/api/getcategorybyid?categoryid=${categoryId}`)
    .then(body => body.json())
    .then(res => {
        console.log(res.result)
        let el = '';
        el += `
    <a href="../index.html">首页></a>
    <a class="all" href="#">全部分类></a>
        <a href="#">${res.result[0].category}</a>
        <span>筛选</span>
    `
        backup.innerHTML = el
        // let history = document.querySelector('.history')
        console.log(history)
        $('.all').on('click' , function () {
            history.back()
        })
    })

// fhzy.onclick = function () {
//     location.href = "../index.html"
// }
